﻿using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Xms.Abp.BackgroundJob;
using Xms.Abp.Threading;

namespace IdentityServerManagement.Tokens;

[BackgroundScheduleName("登录令牌清理")]
public class TokenCleanupBackgroundSchedule : BackgroundSchedule
{
    public TokenCleanupBackgroundSchedule(AsyncCronTimer timer, IServiceScopeFactory serviceScopeFactory)
        : base(timer, serviceScopeFactory)
    {
        CronExpression = "0 0 * * * ? ";
    }

    protected override async Task CreateJobAsync(Guid? tenantId, CancellationToken cancellationToken = default)
    {
        await BackgroundJobManager.EnqueueAsync(new TokenCleanupBackgroundJobArgs(), tenantId);
    }
}
